package admin.student;

import com.alibaba.fastjson2.JSON;
import com.hhkj.admin.student.domain.StudentCourseTrainCount;
import com.ruoyi.RuoYiApplication;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.junit.JunitUtils;
import com.ruoyi.system.domain.StudentLoginLog;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * 练习统计测试层
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RuoYiApplication.class)
@Rollback
public class StudentTrainCount extends AbstractTransactionalJUnit4SpringContextTests {

    /**
     * 1、分页
     */
    @Test
    public void page() {
        String token = JunitUtils.login();
        StudentCourseTrainCount courseTrainCount = new StudentCourseTrainCount();
        TableDataInfo tableDataInfo = JunitUtils.jUnitPost("/train/count/page",
                JSON.toJSONString(courseTrainCount), TableDataInfo.class, token, null);
        for (Object row : tableDataInfo.getRows()) {
            System.out.println(row);
        }
    }

    /**
     * 2、登录日志
     */
    @Test
    public void loginLog() {
        String token = JunitUtils.login();
        StudentLoginLog studentLoginLog = new StudentLoginLog();
        studentLoginLog.setStudentId(20L);
        studentLoginLog.setCourseId(27L);
        TableDataInfo tableDataInfo = JunitUtils.jUnitPost("/train/count/page/login",
                JSON.toJSONString(studentLoginLog), TableDataInfo.class, token, null);
        for (Object row : tableDataInfo.getRows()) {
            System.out.println(row);
        }
    }

    /**
     * 3、培训详情
     */
    @Test
    public void historyPage() {
        String token = JunitUtils.login();
        StudentCourseTrainCount courseTrainCount = new StudentCourseTrainCount();
        courseTrainCount.setStudentId(20L);
        courseTrainCount.setCourseId(27L);
        courseTrainCount.setTypeCode("practice");
        TableDataInfo tableDataInfo = JunitUtils.jUnitPost("/student/train/history/page",
                JSON.toJSONString(courseTrainCount), TableDataInfo.class, token, null);
        for (Object row : tableDataInfo.getRows()) {
            System.out.println(row);
        }
    }
}
